package Arrays;

public class ArrayDemo01 {
    public static void main(String[] args) {
        int[] arrays={1,2,3,4,5};
        int[] arr={1,5,6,7,8};
        //没有下标
        /*for (int array : arrays) {
            System.out.println(array);
        }*/
        //printArray(arrays);
        int[]reverse=reverse(arrays);//reverse方法
        printArray(reverse);
    }
    //打印数组元素
    public static void printArray(int[] arrays){
        for (int i=0;i<arrays.length;i++){
            System.out.print(arrays[i]+" ");
        }
    }
    //反转数组
    public static int[] reverse(int[] x){
        int[] result=new int[x.length];
        //反转操作
        for (int i=0,j=result.length-1;i< x.length;i++,j--){
            result[j]=x[i];
        }
        return result;
    }
}
